package com.qqin.pojo.dto;

import org.apache.ibatis.jdbc.SQL;


public class CheckSqlProvider {

    public String selectByAnySql(String checkId, String checkUser, String checkGoods, String state) {
        return new SQL() {{
            SELECT("*");
            FROM("`check`");
            if (checkId != null && !checkId.isEmpty()) {
                WHERE("check_id = #{checkId}");
            }
            if (checkUser != null && !checkUser.isEmpty()) {
                WHERE("check_user = #{checkUser}");
            }
            if (checkGoods != null && !checkGoods.isEmpty()) {
                WHERE("check_goods = #{checkGoods}");
            }
            if (state != null && !state.isEmpty()) {
                WHERE("state = #{state}");
            }
        }}.toString();
    }

    public String updateByIdSql(String checkId, String state) {
        return new SQL() {{
            UPDATE("`check`");
            if (state != null && !state.isEmpty()) {
                SET("state = #{state}");
            }
            WHERE("check_id = #{checkId}");
        }}.toString();
    }
}

